﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace AAA.Base.Util.Reader
{
    public class XmlParser
    {
        private XmlDocument _xmlDocument;

        public XmlParser(string strFilename)
        {
            try
            {
                _xmlDocument = new XmlDocument();
                _xmlDocument.Load(strFilename);                
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "," + ex.StackTrace);
            }
        }

        public XmlNodeList GetNodes(string strNodeName)
        {
            return _xmlDocument.DocumentElement.SelectNodes(strNodeName);
        }

        public XmlNodeList GetNodes(XmlNode rootNode, string strNodeName)
        {
            return rootNode.SelectNodes(strNodeName);
        }

        public XmlNode GetSingleNode(string strNodeName)
        {
            return _xmlDocument.DocumentElement.SelectSingleNode(strNodeName);
        }

        public XmlNode GetSingleNode(XmlNode rootNode, string strNodeName)
        {
            return rootNode.SelectSingleNode(strNodeName);
        }

    }
}
